import requests
from fake_useragent import UserAgent

# 实例化一个对象
ua = UserAgent().ie

print(ua)

url = 'http://icanhazip.com'
proxies = {
    "http": "http://183.247.211.41:30001",
    "https": "https://121.8.146.99:8060",
}

headers = {
    'User-Agent': ua
}

try:
    response = requests.get(url, proxies=proxies, headers=headers)  # 代理
    print(response.status_code)
    if response.status_code == 200:
        print(response.text)
except requests.ConnectionError as e:
    print(e.args)
